package com.ygxsk.carhome.ui.adapter;

import android.app.Activity;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseNodeAdapter;
import com.chad.library.adapter.base.entity.node.BaseNode;
import com.ygxsk.carhome.response.ParkingLicenseBean;
import com.ygxsk.carhome.ui.park.ParkingSpaceBean;

import java.util.List;

/*
 * @Author:itchenqi175@163.com
 * @Time:2024/1/6  10:03
 * @Description:车辆适配器的外侧包裹内容
 */
public class ParkNodeSectionAdapter extends BaseNodeAdapter {

    private Activity mActivity;

    public ParkNodeSectionAdapter(Activity _activity) {

        super();

        mActivity = _activity;

        //第一层的适配器
        addFooterNodeProvider(new RootNodeProvider(_activity));
        //第二层的适配器
        addNodeProvider(new SecondNodeProvider());

    }

    @Override
    protected int getItemType(@NonNull List<? extends BaseNode> data, int position) {

        BaseNode node = data.get(position);

//        if (node instanceof RootNode) {
        if (node instanceof ParkingSpaceBean) {
            return 0;
        } else if (node instanceof ParkingLicenseBean) {
            //node instanceof ItemNode
            return 1;
        }

//        else if (node instanceof RootFooterNode) {
//            return 2;
//        }

        return -1;
    }
}
